package com.phynos.web.manager.controller;

import java.io.InputStream;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.phynos.web.manager.MyApp;
import com.phynos.web.manager.ui.component.UISidebarMenu;

/**
 * 视图 应用级 基类控制器
 * @author lupc
 *
 */
public class BaseViewController {

	@Autowired
	protected MyApp myapp;
	
	@ModelAttribute(value="myapp")
	public MyApp getMyAppInfo(){
		return myapp;
	}
	
	protected UISidebarMenu getNav() {
		UISidebarMenu nav = null;
		try {
			//转换器 
	        ObjectMapper mapper = new ObjectMapper();
	        InputStream stream = IndexController.class.getResourceAsStream("/ui/menu.json");
	        nav = mapper.readValue(stream, UISidebarMenu.class);
		} catch (Exception e) {
			e.printStackTrace();
		}		
        return nav;
	}
}
